# coding=utf-8
import zmq
import time

context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")

while True:
    message = socket.recv()
    time.sleep (1)
    try:
        reply = str(eval(str(message)))
    except Exception, e:
        reply = 'error:%s' % e
    print 'Received:', message, '\nreply:', reply
    socket.send(reply)